<script src='${rc.getContextPath()}/manage/js/fullcalendar/lang/${lan}.js?v=${ver}'></script>
<link href='${rc.getContextPath()}/manage/js/fullcalendar/fullcalendar.css?v=${ver}' rel='stylesheet' />
<link href='${rc.getContextPath()}/manage/js/fullcalendar/fullcalendar.print.css?v=${ver}' rel='stylesheet' media='print' />
<link rel='stylesheet' href='${rc.getContextPath()}/manage/styles/colorPicker/spectrum.css' />
<style>
.cal {
    margin: 0 auto;
    width: 100%;
    height: 300px;
}

.cal .fc-event {
    width: 100px;
    background: none;
    border: none;
}

.cal .fc-today {
    background: none;
}

.cal .fc-event .fc-content .fc-title {
    color: #666;
}

.fancy {
    width: 450px;
    height: auto
}

.fancy h3 {
    height: 30px;
    line-height: 30px;
    border-bottom: 1px solid #d3d3d3;
    font-size: 14px
}

.fancy form {
    padding: 10px
}

.fancy p {
    height: 28px;
    line-height: 28px;
    padding: 4px;
    color: #999
}

.input {
    height: 20px;
    line-height: 20px;
    padding: 2px;
    border: 1px solid #d3d3d3;
    width: 100px
}

.btn {
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    padding: 5px 12px;
    cursor: pointer
}

.btn_ok {
    background: #360;
    border: 1px solid #390;
    color: #fff
}

.btn_cancel {
    background: #f0f0f0;
    border: 1px solid #d3d3d3;
    color: #666
}

.btn_del {
    background: #f90;
    border: 1px solid #f80;
    color: #fff
}

.sub_btn {
    height: 32px;
    line-height: 32px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
    position: relative
}

.sub_btn .del {
    position: absolute;
    left: 2px
}

.fancy label {
    float: left;
    width: 100px;
    line-height: 23px;
    text-align: left;
}
.cal .fc-title {
    font-size: 14px;
}

#apply .panel .panelHeader
{
height:30px;
}
</style>


<form method="post" action="${rc.getContextPath()}/manage/calendar/saveCalendar" class=" pageForm required-validate" onsubmit="return calendarJs._tsubmit(this);">
    <div class="pageContent">
        <div class="pageFormContent">
            <fieldset>
                <input type="hidden" id="calendarDaysStr" name="calendarDaysStr" value='<#if (calendar.calendarDaysStr)??>${calendar.calendarDaysStr!''}</#if>'> 
                <input type="hidden" name="navTabId" value="${navTabId!''}"> <input type="hidden" name="id" value="<#if (calendar.calendarCode)??>${calendar.calendarCode!''}</#if>">
                <dl>

                    <dt><@label key="calendarCode.C,colon">日历编号：</@label></dt>
                    <dd>
                        <input class="required  alphanumeric toUp" name="calendarCode" value="<#if (calendar.calendarCode)??>${calendar.calendarCode!''}</#if>" type="text" maxlength="20" readonly/>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="calendarText.C,colon">日历描述：</@label></dt>
                    <dd>
                        <input readonly class="required" name="calendarText" value="<#if (calendar.calendarText)??>${calendar.calendarText!''}</#if>" type="text" maxlength="60" />
                    </dd>
                </dl>

                <dl>
                    <dt><@label key="defaultCalendarPattern.C,colon">默认日历模式：</@label></dt>
                    <dd>
                        <select disabled style="width: 147px;" name="calendarPatternCode">
                            <option value=""></option> <#if calendarPatterns??><#if calendarPatterns?size>0><#list calendarPatterns as calendarPattern>
                            <option value="${calendarPattern.calendarPatternCode!''}"  <#if  (calendar.calendarPatternCode)??&& calendar.calendarPatternCode==calendarPattern.calendarPatternCode> selected='selected'</#if>>${calendarPattern.calendarPatternCode!''}-${calendarPattern.calendarPatternText!''}</option> </#list></#if></#if>
                        </select>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="startDate.C,colon">开始日期：</@label></dt>
                    <dd>
                        <input  value="<#if (calendar.startDate)??>${calendar.startDate?string("yyyy-MM-dd")}</#if>" type="text"  readonly/>
                    </dd>
                </dl>
                <dl>
                    <dt><@label key="endDate.C,colon">结束日期：</@label></dt>
                    <dd>
                        <input value="<#if (calendar.endDate)??>${calendar.endDate?string("yyyy-MM-dd")}</#if>" type="text"  readonly/>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dd>
                        <div id='calCalendar' class="cal"></div>
                    </dd>
                </dl>
            </fieldset>
        </div>
          <#assign createInfo=calendar/>
        <#include "/common/createInfo.html">
        <div class="formBar">
            <ul>
                <li><div class="buttonActive" id="save">
                        <div class="buttonContent">
                            <button type="submit"><@label key="save.B">保存</@label></button>
                        </div>
                    </div></li>
                <li>
                    <div class="buttonActiveGrey">
                        <div class="buttonContent">
                            <button type="button" class="close"><@label key="cancel.B">取消</@label></button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</form>

<script type="text/javascript">
Date.prototype.Format = function (fmt) { //author: meizz   
    var o = {
        "M+": this.getMonth() + 1, //月份   
        "d+": this.getDate(), //日   
        "h+": this.getHours(), //小时   
        "m+": this.getMinutes(), //分   
        "s+": this.getSeconds(), //秒   
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度   
        "S": this.getMilliseconds()
        //毫秒   
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "")
                .substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k])
                    : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

var calendarJs = {
    currDialog:null,
    selectDay: "",
    selectText: "",
    calJson: [],
    _getCal: function () {
        return calendarJs.calJson;
    },
    _tsubmit: function (t) {
        $("#calendarDaysStr",calendarJs.currDialog).val(JSON.stringify(calendarJs.calJson));
        return validateCallback(t, dialogAjaxDone);
    }
}

$(function () {
    calendarJs.currDialog=$.pdialog.getCurrent();
   
    var js=$("#calendarDaysStr",calendarJs.currDialog).val();
    var jsArr=eval(js);
    calendarJs.calJson = jsArr;  
    $('#calCalendar',calendarJs.currDialog)
            .fullCalendar(
                    {
                        header: {
                            left: '',
                            center: 'prev,title,next,today',
                            right: ''
                        },
                        height: 300,
                        firstDay: 1,
                        selectable: true,
                        selectHelper: true,
                        unselectAuto: false,
                        editable: false,
                        eventLimit: true,
                        eventClick : function(calEvent, jsEvent, view) {
                            $("#calCalendar",calendarJs.currDialog).fullCalendar('select', calEvent.start);
                        },
                        eventSources: [
                                       // your event source
                                           calendarJs._getCal()
                                       ]
                        });
    $('#calCalendar',calendarJs.currDialog).fullCalendar( 'removeEventSource', calendarJs._getCal() );
    $('#calCalendar',calendarJs.currDialog).fullCalendar( 'addEventSource', calendarJs._getCal() );
    });
</script>
